﻿using System;
using System.Collections.Generic;
using System.Text;

namespace BioCompEx2
{
    class KeyedWord
    {
        private String word;
        private long key;

        public String Word
        {
            get
            {
                return word;
            }
        }

        public long Key
        {
            get
            {
                return key;
            }
        }

        //CTOR
        public KeyedWord(String word)
        {
            this.word = word;
            key = 0;//calcWordKey(word);
        }

        //for "abc" => 1*'a'+10*'b'+100*'c' and so on
        //was "dropped" after testing its afficiancy
        public static long calcWordKey ( String word)
        {
            long calcKey = 0;
            char[] letters = word.ToCharArray();
            long num = 1;
            for (int i = 0; i < letters.Length; i++)
            {
                calcKey += (Convert.ToInt32(letters[i])-97) * num;
                num *= 10;
            }
            return calcKey;
        }
    }
}
